<template>
  <div id="printJS-form" class="c-org-print">
    <el-table
      ref="print-table"
      :data="printData"
      style="width: 800px; text-align: left"
      border
    >
      <el-table-column
        v-for="(item, index) in organizationColumn"
        :key="index"
        :prop="item.prop"
        :label="item.label"
        header-align="center"
        align="center"
      >
        <template slot-scope="scope">
          <template v-if="scope.column.property == 'tradeType'">
            {{ scope.row.tradeType != null ?tradeTypeList.find(i => i.encode ==scope.row.tradeType ).name:'' }}
          </template>
          <template v-else-if="scope.column.property == 'type'">
            {{ scope.row.type?typeList.find(i => i.encode ==scope.row.type).name:'' }}
          </template>
          <template v-else>
            {{ scope.row[scope.column.property] }}
          </template>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  props: {
    printData: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      tradeTypeList: [
        { encode: 0, name: '行政单位' },
        { encode: 1, name: '事业单位' },
        { encode: 2, name: '村集体经济组织' },
        { encode: 3, name: '其他' }
      ],
      typeList: [
        { encode: '0', name: '常用组织' },
        { encode: '1', name: '总预算组织' },
        { encode: '2', name: '支付中心组织' },
        { encode: '3', name: '统管组织' }
      ],
      organizationColumn: [
        {
          label: '组织编码',
          prop: 'encode',
          width: 150
        },
        {
          label: '组织名称',
          prop: 'name',
          width: 120
        },
        {
          label: '统一社会信用社代码',
          prop: 'enterpriseCode',
          minWidth: 240
        },
        {
          label: '行业属性',
          prop: 'tradeType',
          width: 120
        },
        {
          label: '组织类型',
          prop: 'type',
          width: 120
        },
        {
          label: '所属组织单元',
          prop: 'orgGroupName',
          minWidth: 240
        },
        {
          label: '单位负责人',
          prop: 'manager',
          width: 120
        },
        {
          label: '联系电话',
          prop: 'managerMobile',
          width: 120
        }
      ]
    }
  }
}
</script>

<style lang="scss" scoped>
  .c-org-print {
    transform: translate3d(9999px, 9999px, 1px);
    height: 100%;
    visibility: hidden;
    position: fixed;
    left: 0;
    top: 0;
  }
</style>
